package edu.cmu.fithub.formbeans;

import java.util.ArrayList;
import java.util.List;

import org.mybeans.form.FormBean;

public class PostForm extends FormBean {

	private String post;

	public String getPost() {
		return post;
	}

	public void setPost(String post) {
		this.post = post;
	}

	public List<String> getValidationErrors() {
		List<String> errors = new ArrayList<String>();

		if (post == null || post.length() == 0) {
			errors.add("Post is required");
		} else if (post.matches(".*[<>].*")) {
			errors.add("Post may not contain angle brackets");
			post = post.replaceAll(">", "&gt;");
			post = post.replaceAll("<", "&lt;");
		}
		return errors;
	}
}
